<template>
	<view>
		<view class="list" @click="information(item.order_id)" v-for="(item,index) in list">
			<view class="box">
				<view class="title">{{item.title}}</view>
				<view class="time">{{item.createtime}}</view>
			</view>
			<view :class="item.money<0?'colors money':'money'">{{item.money<0?'-￥':'￥'}}{{item.money<0?-item.money:item.money}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				page:0,
				loading:false,
			}
		},
		onLoad(){
			
		},
		onShow(){
			this.page=0;
			this.listOrder();
		},
		onPullDownRefresh() {
			this.page=0;
			this.listOrder();
		},
		onReachBottom() {
			this.listOrder();
		},
		methods: {
			information(order_id) {
				console.log(order_id)
				if(0==order_id){
					return;
				}
				// uni.navigateTo({
				// 	url: '/pages/dispatch/information/information'
				// })
				uni.navigateTo({
					url: '/pages/dispatch/complaint/complaint?order_id='+order_id
				})
			},
			async listOrder(){
				if(this.loading){
					return;
				}
				this.loading = true;
				uni.showLoading({
					title: '加载中'
				});
				if(0==this.page){
					this.list = [];
				}
				this.page++;
				// 获取列表
				await uni.request({
					url: '/dispatch/server/listMoneyLog',
					data: {
						page:this.page
					},
					method:"POST",
					success: res => {
						this.list = this.list.concat(res.data);
						console.log(res);
					},
					complete:()=>{
						setTimeout(()=>{
							uni.stopPullDownRefresh();
							uni.hideLoading();
							this.loading = false;
						},100)
					}
				});	
			},
		}
	}
</script>

<style>
	page {
		background-color: #f7f7f7;
		display: flex;
		justify-content: center;
		flex-wrap: wrap;
		padding-top: 30rpx;
	}

	.list {
		width: 688rpx;
		height: 164rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
		margin-bottom: 30rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.box {
		margin-left: 40rpx;
	}

	.money {
		margin-right: 30rpx;
		font-size: 34rpx;
		color: #333333;
	}

	.colors {
		color: #84BD00;
	}

	.title {
		font-size: 30rpx;
		color: #333333;
	}

	.time {
		font-size: 26rpx;
		color: #999999;
		margin-top: 20rpx;
	}
</style>